<%@ Page Title="" Language="C#" MasterPageFile="~/Pages/admin/adminMaster.Master" AutoEventWireup="true" CodeBehind="EditUsers.aspx.cs" Inherits="WarehouseWebAPP.Pages.admin.Edit_Entities.EditUsers" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="style1">
    <tr>
        <td>
                            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                                <ContentTemplate>
                                    <asp:Label ID="ErrorLabel" runat="server" BackColor="#FFFFCC" 
                                ForeColor="Maroon" Height="24px" 
                                Text="Error: The entity can't be deleted from the following reason: This entity is a FK of other entity." 
                                Visible="False" Width="561px"></asp:Label>
                                    <asp:GridView ID="UsersGridView" runat="server" AllowPaging="True" 
                                        AllowSorting="True" AutoGenerateColumns="False" CellPadding="4" 
                                        DataKeyNames="user_num" DataSourceID="UsersObjectDataSource" 
                                        ForeColor="#333333" GridLines="None" 
                                        onselectedindexchanged="UsersGridView_SelectedIndexChanged" PageSize="4" 
                                        Width="675px">
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <Columns>
                                            <asp:CommandField ShowSelectButton="True" />
                                            <asp:BoundField DataField="user_num" HeaderText="user_num" ReadOnly="True" 
                                                SortExpression="user_num" Visible="False" />
                                            <asp:BoundField DataField="user_id" HeaderText="User ID No." 
                                                SortExpression="user_id" />
                                            <asp:BoundField DataField="user_name" HeaderText="User Name" 
                                                SortExpression="user_name" />
                                            <asp:BoundField DataField="user_address" HeaderText="Address" 
                                                SortExpression="user_address" Visible="False" />
                                            <asp:BoundField DataField="user_phone" HeaderText="Phone No." 
                                                SortExpression="user_phone" />
                                            <asp:BoundField DataField="user_email" HeaderText="E-mail Address" 
                                                SortExpression="user_email" />
                                            <asp:BoundField DataField="user_type" HeaderText="user_type" 
                                                SortExpression="user_type" Visible="False" />
                                            <asp:BoundField DataField="user_login_name" HeaderText="user_login_name" 
                                                SortExpression="user_login_name" Visible="False" />
                                            <asp:BoundField DataField="user_password" HeaderText="user_password" 
                                                SortExpression="user_password" Visible="False" />
                                        </Columns>
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" 
                                            HorizontalAlign="Left" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:GridView>
                                    <asp:Label ID="WarningLabel" runat="server" BackColor="#FFFFCC" 
                                        BorderStyle="Double" ForeColor="Maroon" Height="24px" 
                                        Text="Warning: Editing User's details will reset his password."></asp:Label>
                                    <br />
                                    <asp:DetailsView ID="UserDetailsView" runat="server" AutoGenerateRows="False" 
                                        CellPadding="4" DataKeyNames="user_num" DataSourceID="UsersObjectDataSource" 
                                        ForeColor="#333333" GridLines="None" Height="50px" 
                                        ondatabound="UserDetailsView_DataBound" 
                                        onitemdeleting="UserDetailsView_ItemDeleting" Width="555px">
                                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                                        <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                        <Fields>
                                            <asp:BoundField DataField="user_num" HeaderText="user_num" ReadOnly="True" 
                                                SortExpression="user_num" Visible="False" />
                                            <asp:TemplateField HeaderText="User ID No." SortExpression="user_id">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="IDTextBox" runat="server" Text='<%# Bind("user_id") %>' 
                                                        ToolTip=" 9 Digits"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                                        ControlToValidate="IDTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
                                                        ControlToValidate="IDTextBox" ErrorMessage="Invalid ID" ToolTip=" 9 Digits" 
                                                        ValidationExpression="\d{9}"></asp:RegularExpressionValidator>
                                                    <asp:CustomValidator ID="CustomValidator1" runat="server" 
                                                        ControlToValidate="IDTextBox" ErrorMessage="Already Exist" 
                                                        onservervalidate="CustomValidator1_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("user_id") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("user_id") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="User Name" SortExpression="user_name">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("user_name") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                        ControlToValidate="NameTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:CustomValidator ID="CustomValidator2" runat="server" 
                                                        ControlToValidate="NameTextBox" ErrorMessage="Already Exist" 
                                                        onservervalidate="CustomValidator2_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("user_name") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="UserLabel" runat="server" Text='<%# Bind("user_name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:BoundField DataField="user_address" HeaderText="Address" 
                                                SortExpression="user_address" />
                                            <asp:TemplateField HeaderText="Phone No." SortExpression="user_phone">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("user_phone") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                                                        ControlToValidate="TextBox3" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                                                        ControlToValidate="TextBox3" ErrorMessage="Invalid Phone No." 
                                                        ValidationExpression="^0[23489]{1}(\-)?[^0\D]{1}\d{6}$|^0(5[012345678]){1}(\-)?\d{7}$"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("user_phone") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("user_phone") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="E-mail Address" SortExpression="user_email">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("user_email") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                                                        ControlToValidate="TextBox4" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                                                        ControlToValidate="TextBox4" ErrorMessage="Invalid E-mail" 
                                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("user_email") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("user_email") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="User Type" SortExpression="user_type">
                                                <EditItemTemplate>
                                                    <asp:DropDownList ID="DropDownList1" runat="server" 
                                                        DataSourceID="UserTypeObjectDataSource" DataTextField="user_type" 
                                                        DataValueField="user_type_num" SelectedValue='<%# Bind("user_type") %>'>
                                                    </asp:DropDownList>
                                                    <asp:ObjectDataSource ID="UserTypeObjectDataSource" runat="server" 
                                                        SelectMethod="UserTypeGet" TypeName="WarehouseWebAPP.code.BLL.UserTypeBLL">
                                                    </asp:ObjectDataSource>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("user_type") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="TypeLabel" runat="server" Text='<%# Bind("user_type") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="User Login Name" 
                                                SortExpression="user_login_name">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="LoginTextBox" runat="server" 
                                                        Text='<%# Bind("user_login_name") %>'></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" 
                                                        ControlToValidate="LoginTextBox" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" 
                                                        ControlToValidate="LoginTextBox" ErrorMessage="Invalid Username." 
                                                        ToolTip="Refer User Manual." ValidationExpression="^[a-zA-Z0-9_]{5,20}$"></asp:RegularExpressionValidator>
                                                    <asp:CustomValidator ID="CustomValidator3" runat="server" 
                                                        ControlToValidate="LoginTextBox" ErrorMessage="Already Exist" 
                                                        onservervalidate="CustomValidator3_ServerValidate"></asp:CustomValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("user_login_name") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("user_login_name") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderText="User Login Password" 
                                                SortExpression="user_password">
                                                <EditItemTemplate>
                                                    <asp:Label ID="Label9" runat="server" ForeColor="#E9ECF1" Text="Type Password:"></asp:Label>
                                                    &nbsp;&nbsp;
                                                    <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("user_password") %>' 
                                                        TextMode="Password" Width="128px"></asp:TextBox>
                                                    <cc1:PasswordStrength ID="TextBox6_PasswordStrength" runat="server" 
                                                        TargetControlID="TextBox6" 
                                                        TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent" 
                                                        TextStrengthDescriptionStyles="cssClass1;cssClass1;cssClass1;cssClass1;cssClass1">
                                                    </cc1:PasswordStrength>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" 
                                                        ControlToValidate="TextBox6" ErrorMessage="*"></asp:RequiredFieldValidator>
                                                    <br />
                                                    <asp:Label ID="Label8" runat="server" ForeColor="#E9ECF1" 
                                                        Text="Verify Password:"></asp:Label>
                                                    &nbsp;
                                                    <asp:TextBox ID="ValidateTextBox" runat="server" TextMode="Password" 
                                                        Width="128px"></asp:TextBox>
                                                    <asp:CompareValidator ID="CompareValidator1" runat="server" 
                                                        ControlToCompare="TextBox6" ControlToValidate="ValidateTextBox" 
                                                        ErrorMessage="Verification Failed."></asp:CompareValidator>
                                                </EditItemTemplate>
                                                <InsertItemTemplate>
                                                    <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("user_password") %>'></asp:TextBox>
                                                </InsertItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label7" runat="server" ForeColor="Red" Text="Confidential"></asp:Label>
                                                    <br />
                                                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("user_password") %>' 
                                                        Visible="False"></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                                        </Fields>
                                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                        <EditRowStyle BackColor="#999999" />
                                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                    </asp:DetailsView>
                                </ContentTemplate>
                            </asp:UpdatePanel>
        </td>
    </tr>
    <tr>
        <td>
            <asp:ObjectDataSource ID="UsersObjectDataSource" runat="server" DeleteMethod="UserDelete" 
                    SelectMethod="userGet" TypeName="WarehouseWebAPP.code.BLL.UserBLL" 
                    UpdateMethod="UserUpdate">
                <UpdateParameters>
                    <asp:Parameter Name="user_id" Type="String" />
                    <asp:Parameter Name="user_name" Type="String" />
                    <asp:Parameter Name="user_address" Type="String" />
                    <asp:Parameter Name="user_phone" Type="String" />
                    <asp:Parameter Name="user_email" Type="String" />
                    <asp:Parameter DbType="Guid" Name="user_type" />
                    <asp:Parameter Name="user_login_name" Type="String" />
                    <asp:Parameter Name="user_password" Type="String" />
                    <asp:Parameter DbType="Guid" Name="user_num" />
                </UpdateParameters>
            </asp:ObjectDataSource>
        </td>
    </tr>
    </table>
</asp:Content>
